package com.example.javaffmpeg.config;

import com.example.javaffmpeg.bean.Room;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
@ConfigurationProperties(prefix = "rooms")
public class RoomsConfig {
    private Map<String,Room> map;
    private List<Room> list;
    @Value("rootUrl")
    private String rootUrl;
    @Value("nginxIp")
    private String nginxIp;
    @Value("nginxPort")
    private String nginxPort;



    public List<Room> getList() {
        return list;
    }
    public Map<String,Room> getMap() {
        return map;
    }

    public String getRootUrl() {
        return rootUrl;
    }

    public void setRootUrl(String rootUrl) {
        this.rootUrl = rootUrl;
    }
    //将地址拼接起来。存起来
    public void setList(List<Room> list) {
        Map<String,Room> map =new HashMap<String, Room>();
        for (Room room:list) {
            map.put(room.getName(),room);

        }
        this.map = map;
        this.list = list;
    }

    @Override
    public String toString() {
        return "RoomsConfig{" +
                "list.size() =" + list.size() +
                '}';
    }

    public String getNginxIp() {
        return nginxIp;
    }

    public void setNginxIp(String nginxIp) {
        this.nginxIp = nginxIp;
    }

    public String getNginxPort() {
        return nginxPort;
    }

    public void setNginxPort(String nginxPort) {
        this.nginxPort = nginxPort;
    }
}
